package com.demo.mantis.web;

import javax.inject.Inject;
import javax.inject.Singleton;

import cn.techarts.dragonfly.web.WebContext;
import cn.techarts.dragonfly.web.rest.Get;
import cn.techarts.dragonfly.web.rest.Restful;
import com.demo.mantis.service.CalculatorService;

@Singleton
@Restful
public class CalculatorWebService {

	@Inject
	private CalculatorService service;

	@Get("/plus/{x}/{y}")
	public float plus(WebContext arg) {
		var x = arg.floatAt(0);
		var y = arg.floatAt(1);
		return service.plus(x,y);
	}
	
	@Get("/subtract/{x}/{y}")
	public float subtract(WebContext arg) {
		var x = arg.floatAt(0);
		var y = arg.floatAt(1);
		return service.subtract(x,y);
	}
	
	@Get("/multiply/{x}/{y}")
	public float multiply(WebContext arg) {
		var x = arg.floatAt(0);
		var y = arg.floatAt(1);
		return service.multiply(x,y);
	}
	
	@Get("/divide/{x}/{y}")
	public float divide(WebContext arg) {
		var x = arg.floatAt(0);
		var y = arg.floatAt(1);
		return service.divide(x,y);
	}
}
